﻿using System;
using System.Web.Mvc;
using HtmlAgilityPack;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Mvc.RazorTools.Glyphicons.Tests
{
	[TestClass]
	public class HtmlExtensionsTests
	{
		[TestMethod]
		[TestCategory("HtmlExtensionsTests")]
		public void HtmlExtensionsTest1()
		{
			ViewContext vc = new ViewContext();
			ViewData data = new ViewData();
			HtmlHelper html = new HtmlHelper(vc, data);

			MvcHtmlString result = html.Glyphicons(GlyphiconsSet.Free.Flag);
			HtmlNode node = result.HtmlNode();
			Assert.AreEqual(true, node.Attributes.Contains("class"));
			Assert.AreEqual(true, node.Attributes["class"].Value.Contains(GlyphiconsSet.Free.Flag.IconId));
		}

		[TestMethod]
		[TestCategory("HtmlExtensionsTests")]
		public void HtmlExtensionsTest2()
		{
			ViewContext vc = new ViewContext();
			ViewData data = new ViewData();
			HtmlHelper html = new HtmlHelper(vc, data);

			MvcHtmlString result = html.Glyphicons(GlyphiconsSet.Free.Flag.Customize("value1"));
			HtmlNode node = result.HtmlNode();
			Assert.AreEqual(true, node.Attributes.Contains("class"));
			Assert.AreEqual(true, node.Attributes["class"].Value.Contains(GlyphiconsSet.Free.Flag.IconId));
			Assert.AreEqual(true, node.Attributes["class"].Value.Contains("value1"));
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentNullException))]
		public void HtmlExtensionsTest3()
		{
			HtmlHelper html = null;
			MvcHtmlString result = html.Glyphicons(GlyphiconsSet.Free.Flag);
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentNullException))]
		public void HtmlExtensionsTest4()
		{
			ViewContext vc = new ViewContext();
			ViewData data = new ViewData();
			HtmlHelper html = new HtmlHelper(vc, data);

			MvcHtmlString result = html.Glyphicons(null);
		}
	}
}
